package com.gscitysfy.cus.drain.modules.pipe.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.annotations.DictTranslation;
import com.gscitysfy.cus.drain.annotations.FieldParam;
import com.gscitysfy.cus.drain.constants.DicConstant;
import com.gscitysfy.cus.drain.modules.pipe.entity.DrainPipeHiddenDangerRectify;
import com.gscitysfy.cus.drain.modules.pipe.service.IDrainPipeHiddenDangerRectifyService;
import com.gscitysfy.cus.drain.modules.pipe.vo.HiddenDangerRectifyDetailVo;
import com.gscitysfy.cus.drain.modules.pipe.vo.HiddenDangerRectifyFeedbackVo;
import com.gscitysfy.cus.drain.modules.pipe.vo.HiddenDangerRectifyQueryVo;
import groovy.lang.Lazy;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 隐患整改 前端控制器
 * </p>
 *
 * @author Axi
 * @since 2022-11-16 12:06:33
 */
@RestController
@RequestMapping("/pipe/rectify")
@Tag(name = "管网隐患管理 -> 隐患整改")
public class DrainPipeHiddenDangerRectifyController {

    @Resource
    @Lazy
    IDrainPipeHiddenDangerRectifyService rectifyService;

    @Operation(summary = "查询整改信息列表", description = "查询整改信息列表接口")
    @PostMapping("/pageList")
    @DictTranslation({
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_SOURCE, targetField = "hiddenDangerSource"),
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_CATEGORY, targetField = "hiddenDangerCategory"),
            @FieldParam(dictType = DicConstant.RECTIFY_FEEDBACK_TYPE, targetField = "feedbackType")
    })
    public Result<IPage<DrainPipeHiddenDangerRectify>> getPageList(@RequestBody HiddenDangerRectifyQueryVo queryVo) {
        return Result.content(rectifyService.getPageList(queryVo));
    }

    @Operation(summary = "反馈进度", description = "反馈进度接口")
    @PutMapping(value = "/feedbackProcess")
    public Result<Boolean> feedbackProcess(@RequestBody HiddenDangerRectifyFeedbackVo feedbackVo) {
        return rectifyService.feedback(feedbackVo) ? Result.success() : Result.failure();
    }

    @Operation(summary = "获取整改信息详情", description = "获取整改信息详情接口")
    @GetMapping("/detail")
    @DictTranslation({
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_SOURCE, targetField = "hiddenDangerSource"),
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_CATEGORY, targetField = "hiddenDangerCategory"),
            @FieldParam(dictType = DicConstant.RECTIFY_FEEDBACK_TYPE, targetField = "feedbackType")
    })
    public Result<HiddenDangerRectifyDetailVo> getDetailById(Long id) {
        return Result.content(rectifyService.detailById(id));
    }

}
